﻿// -----------------------------------------------------------------------
// <copyright file="ModelCache.cs" company="Microsoft">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.IO;
using System.Linq;
using BCS.Model;

namespace BCS.Business
{
        /// <summary>
        /// TODO: Update summary.
        /// </summary>
        public static class ModelCache
        {
                public static List<TeamModel> TeamModels { get; private set; }

                public static List<RecordModel> RecordModels { get; private set; }

                public static CameraModel CameraModel { get; private set; }

                public static DataContext DataContext { get; private set; }

                public static Table<CameraModel> CameraTable { get; private set; }

                public static Table<RecordModel> RecordTable { get; private set; }

                public static Table<TeamModel> TeamTable { get; private set; }

                public static bool Load()
                {
                        DataContext = new DataContext(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Data\Data.sdf"));

                        RecordTable = DataContext.GetTable<RecordModel>();
                        RecordModels = RecordTable.ToList();

                        TeamTable = DataContext.GetTable<TeamModel>();
                        TeamModels = TeamTable.ToList();

                        CameraTable = DataContext.GetTable<CameraModel>();
                        CameraModel = CameraTable.First();

                        return true;
                }
        }
}